import { IPSAppDEFLogic } from './ipsapp-deflogic';
import { IPSAppDEFUIMode } from './ipsapp-defuimode';
import { IPSAppDEField } from './ipsapp-defield';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEFieldImpl2 extends PSModelObjectImpl implements IPSAppDEField {
  protected allpsappdefuimodes: IPSAppDEFUIMode[] | null = null;

  getAllPSAppDEFUIModes(): IPSAppDEFUIMode[] | null {
    if (this.allpsappdefuimodes == null) {
      this.allpsappdefuimodes = this.fillChildListModel(this.M.getAllPSAppDEFUIModes, 'app.dataentity.IPSAppDEFUIMode') as IPSAppDEFUIMode[];
    }
    return this.allpsappdefuimodes;
  }

  get allPSAppDEFUIModes(): IPSAppDEFUIMode[] | null {
    return this.getAllPSAppDEFUIModes();
  }

  findPSAppDEFUIMode(objKey: any): IPSAppDEFUIMode | null {
    return this.getPSModel5('app.dataentity.IPSAppDEFUIMode', this.getAllPSAppDEFUIModes(), objKey) as IPSAppDEFUIMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  protected computepsappdeflogic: IPSAppDEFLogic | null = null;

  getComputePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.computepsappdeflogic != null) return this.computepsappdeflogic;
    const value = this.M.getComputePSAppDEFLogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.computepsappdeflogic = ipsappdataentity.findPSAppDELogic(value) as IPSAppDEFLogic;
    }
    return this.computepsappdeflogic;
  }

  get computePSAppDEFLogic(): IPSAppDEFLogic | null {
    return this.getComputePSAppDEFLogic();
  }

  getComputePSAppDEFLogicMust(): IPSAppDEFLogic {
    const value = this.getComputePSAppDEFLogic();
    if (value == null) {
      throw new Error('未指定值计算逻辑');
    }
    return value;
  }

  get defaultValue(): string {
    return this.M.defaultValue;
  }

  protected defaultvaluepsappdeflogic: IPSAppDEFLogic | null = null;

  getDefaultValuePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.defaultvaluepsappdeflogic != null) return this.defaultvaluepsappdeflogic;
    const value = this.M.getDefaultValuePSAppDEFLogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.defaultvaluepsappdeflogic = ipsappdataentity.findPSAppDELogic(value) as IPSAppDEFLogic;
    }
    return this.defaultvaluepsappdeflogic;
  }

  get defaultValuePSAppDEFLogic(): IPSAppDEFLogic | null {
    return this.getDefaultValuePSAppDEFLogic();
  }

  getDefaultValuePSAppDEFLogicMust(): IPSAppDEFLogic {
    const value = this.getDefaultValuePSAppDEFLogic();
    if (value == null) {
      throw new Error('未指定默认值逻辑');
    }
    return value;
  }

  get defaultValueType(): 'SESSION' | 'APPLICATION' | 'UNIQUEID' | 'CONTEXT' | 'PARAM' | 'OPERATOR' | 'OPERATORNAME' | 'CURTIME' | 'APPDATA' | 'EXPRESSION' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.defaultValueType;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected lnpslanguageres: IPSLanguageRes | null = null;

  getLNPSLanguageRes(): IPSLanguageRes | null {
    if (this.lnpslanguageres != null) return this.lnpslanguageres;
    const value = this.M.getLNPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.lnpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getLNPSLanguageRes') as IPSLanguageRes;
    return this.lnpslanguageres;
  }

  get lNPSLanguageRes(): IPSLanguageRes | null {
    return this.getLNPSLanguageRes();
  }

  getLNPSLanguageResMust(): IPSLanguageRes {
    const value = this.getLNPSLanguageRes();
    if (value == null) {
      throw new Error('未指定逻辑名称语言资源');
    }
    return value;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get maxValueString(): string {
    return this.M.maxValueString;
  }

  get memo(): string {
    return this.M.memo;
  }

  get minStringLength(): number {
    return this.M.minStringLength != null ? this.M.minStringLength : 0;
  }

  get minValueString(): string {
    return this.M.minValueString;
  }

  get name(): string {
    return this.M.name;
  }

  protected onchangepsappdeflogic: IPSAppDEFLogic | null = null;

  getOnChangePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.onchangepsappdeflogic != null) return this.onchangepsappdeflogic;
    const value = this.M.getOnChangePSAppDEFLogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.onchangepsappdeflogic = ipsappdataentity.findPSAppDELogic(value) as IPSAppDEFLogic;
    }
    return this.onchangepsappdeflogic;
  }

  get onChangePSAppDEFLogic(): IPSAppDEFLogic | null {
    return this.getOnChangePSAppDEFLogic();
  }

  getOnChangePSAppDEFLogicMust(): IPSAppDEFLogic {
    const value = this.getOnChangePSAppDEFLogic();
    if (value == null) {
      throw new Error('未指定值变更逻辑');
    }
    return value;
  }

  get precision(): number {
    return this.M.precision != null ? this.M.precision : 0;
  }

  protected qsphpslanguageres: IPSLanguageRes | null = null;

  getQSPHPSLanguageRes(): IPSLanguageRes | null {
    if (this.qsphpslanguageres != null) return this.qsphpslanguageres;
    const value = this.M.getQSPHPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.qsphpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getQSPHPSLanguageRes') as IPSLanguageRes;
    return this.qsphpslanguageres;
  }

  get qSPHPSLanguageRes(): IPSLanguageRes | null {
    return this.getQSPHPSLanguageRes();
  }

  getQSPHPSLanguageResMust(): IPSLanguageRes {
    const value = this.getQSPHPSLanguageRes();
    if (value == null) {
      throw new Error('未指定快速搜索占位提示信息语言资源');
    }
    return value;
  }

  get quickSearchPlaceHolder(): string {
    return this.M.quickSearchPlaceHolder;
  }

  get stdDataType(): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 {
    return this.M.stdDataType;
  }

  get stringLength(): number {
    return this.M.stringLength != null ? this.M.stringLength : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get dataTypeField(): boolean {
    return this.M.dataTypeField != null ? this.M.dataTypeField : false;
  }

  get enableFrontOnly(): boolean {
    return this.M.enableFrontOnly != null ? this.M.enableFrontOnly : false;
  }

  get enableQuickSearch(): boolean {
    return this.M.enableQuickSearch != null ? this.M.enableQuickSearch : false;
  }

  get keyField(): boolean {
    return this.M.keyField != null ? this.M.keyField : false;
  }

  get majorField(): boolean {
    return this.M.majorField != null ? this.M.majorField : false;
  }

  get cls(): string {
    return 'PSAppDEFieldImpl2';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEField' || cls == 'app.dataentity.IPSAppDataEntityObject') return true;
    return super.instanceof(cls);
  }
}
